﻿#include "C3fdInputNameDialog.h"
#include "ui_C3fdInputNameDialog.h"
#include <QMessageBox>

C3fdInputNameDialog::C3fdInputNameDialog(QString defaultName, QWidget *parent)
	: QDialog(parent), m_Name(defaultName), m_Ui(new Ui::C3fdInputNameDialog)
{
	m_Ui->setupUi(this);
	m_Ui->le_Name->setText(m_Name);
}

C3fdInputNameDialog::~C3fdInputNameDialog()
{
	delete m_Ui;
}

void C3fdInputNameDialog::on_buttonBox_accepted()
{
	QString name = m_Ui->le_Name->text().simplified();
	if (!name.isEmpty())
	{
		m_Name = name;
	}
	else
	{
		QMessageBox::critical(this, tr("Error Info"), tr("Please enter the working condition name!"));
		return;
	}
}

void C3fdInputNameDialog::on_buttonBox_rejected()
{
}

QString C3fdInputNameDialog::getName() const
{
	return m_Name;
}